home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
machack
/
Hacks96
/
FlyPaper.sit
/
Fly Paper
/
FlyPaper Source
/
App Sources
/
patches.c
< prev
next >
Wrap
Text File
|
1996-06-22
|
3KB
|
89 lines
// File "patches.c" -
#include <Traps.h>
#include <Windows.h>
#include "patches.h"
#include "FlyPaperApp.h"
// ***********************************************************************************
// Global Declarations
ExitToShellUPP gSaveExitToShell;
ExitToShellUPP gExitToShellPatch = 0;
NewWindowUPP gNewWindowPatch=0;
// ***********************************************************************************
// ***********************************************************************************
void PatchExitToShell() {
short trap = _ExitToShell;
if (! gExitToShellPatch) gExitToShellPatch = NewExitToShellProc(MyExitToShell);
if (! gExitToShellPatch) return;
gSaveExitToShell = (ExitToShellUPP)
NGetTrapAddress(trap, (trap & 0x0800) ? ToolTrap : OSTrap);
NSetTrapAddress((UniversalProcPtr) gExitToShellPatch,
trap, (trap & 0x0800) ? ToolTrap : OSTrap);
}
// ***********************************************************************************
// ***********************************************************************************
pascal void MyExitToShell() {
static Boolean done = false;
long saveA5;
ExitToShellUPP tempSaveExitToShell;
// Setup (68k) globals in case we are ES-ing from deep within Macsbug.
saveA5 = SetCurrentA5();
// Our ExitToShell() patch may cause re-entrancy problems... so we bracket
// the functional calls by checking and setting a one-time flag.
if (! done) {
done = true;
Finalize ();
}
// Save off the global pointer while we still have our 68K A5-World set up
tempSaveExitToShell = gSaveExitToShell;
SetA5(saveA5);
CallExitToShellProc(tempSaveExitToShell);
}
// ***********************************************************************************
// ***********************************************************************************
void PatchNewWindow(void) {
short trap = _NewWindow;
if (! gNewWindowPatch) gNewWindowPatch = NewNewWindowProc(MyNewWindow);
if (! gNewWindowPatch) return;
NSetTrapAddress((UniversalProcPtr) gNewWindowPatch,
trap, (trap & 0x0800) ? ToolTrap : OSTrap);
}
// ***********************************************************************************
// ***********************************************************************************
pascal WindowPtr MyNewWindow(Ptr wStorage, Rect *bounds, StringPtr title,
Boolean vis, short procID, WindowPtr behind, Boolean close, long refCon) {
short trap = _NewCWindow;
WindowPtr win;
NewWindowUPP myNewCWindow;
// Call NewCWindow in place of NewWindow!
myNewCWindow = (NewWindowUPP)
NGetTrapAddress(trap, (trap & 0x0800) ? ToolTrap : OSTrap);
win = CallNewWindowProc(myNewCWindow, wStorage, bounds, title, vis, procID,
behind, close, refCon);
return(win);
}